/*

 * @(#) QuerySqlUtil.java

 *

 * Company        : Cherubim Enterprise Solutions Ltd.

 * Copyright      : Copyright (c) 2002-2010 Cherubim Enterprise Solutions Ltd.  All rights reserved.

 * Created        : Jul-13-2010

 *

 */
package com.ces.newPOS.admin.dao.server.util;

//import hk.ces.oxfam.admin.entity.obj.SQLLikeSearchPattern;
import javax.persistence.Query;
import org.apache.log4j.Logger;

/**
 * @author  chaoquan huang
 */
public class QuerySqlUtil
{

  public static void setParams(Query query, String sql, String param, Object paramValue)
  {
    if (sql.contains(param))
    {
      query.setParameter(param.replaceAll(":", ""), paramValue);
      Logger.getLogger(QuerySqlUtil.class).debug("SQL = " + sql + ", PARAM = " + param + ", PARAM VALUE = " + paramValue);
    }
  }

//  public static String getLikeString(String likeValue, SQLLikeSearchPattern likeSearchPattern)
//  {
//    switch (likeSearchPattern)
//    {
//      case LEFT_LIKE:
//        return getLeftLikeString(likeValue);
//      case RIGHT_LIKE:
//        return getRightLikeString(likeValue);
//      case ALL_LIKE:
//      default:
//        return getAllLikeString(likeValue);
//    }
//  }

  public static String getLeftLikeString(String likeValue)
  {
    return "%" + likeValue;
  }

  public static String getRightLikeString(String likeValue)
  {
    return likeValue + "%";
  }

  public static String getAllLikeString(String likeValue)
  {
    return "%" + likeValue + "%";
  }
}
